package com.example.springmvc_adv.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName AppConfig
 * @Description TODO
 * @Author H.
 * @Date 2023/4/27 20:23
 * @Version 1.0
 */
@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
//        configurer.addPathPrefix("api", c ->{
//            System.out.println(c.getClass());
//            return true;
//        });
    }

    /**
     * 添加拦截器(可以添加多个)
     * @param registry  拦截器注册器(注册拦截器，通过路径规则 + 拦截器对象)
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginInterceptor())
//                //拦截所有后端路径
//                .addPathPatterns("/api/**")
//                //排除登录和注册窗口
//                .excludePathPatterns("/api/user/login")
//                .excludePathPatterns("/api/user/register");
    }
}
